Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
generate-js-events
Advanced tools
A generator for EventEmitter, lets you create an objects that can emit events.
A generator for EventEmitter, lets you create an objects that can emit events, or generate a new generator that inherits from EventEmitter.
$ npm install generate-js-events
Object
A new object that inherits from EventEmitter.Creates a new object that inherits from EventEmitter.
Example:
var EventEmitter = require('generate-js-events');
var myEmitter = new EventEmitter();
Function
Create method that gets called when creating a new object that inherits from EventEmitter.Generator
A new generator that inherits from EventEmitter.Returns a new generator that inherits from EventEmitter.
Example:
var myGenerator = EventEmitter.generate(
/* create method */
function myGenerator() {
// my create code here
}
);
myGenerator.definePrototype(
{
// my descriptor here
},
{
// my prototype here
}
);
A new generator that inherits from the generator that generated it using the EventEmitter.generate(create) method.
A new object that inherits from the generator that created it using the new EventEmitter() method.
String
Name of event.Function
Event handler function.Object
Object reference for binding.Object
This object.Adds a 'listener' on 'event' to this EventEmitter instance.
Example:
/*
* Set lestener.
* NOTE: myEmitter.off('error') does not remove *this* listener.
*/
myEmitter.onerror = function (err) {
console.log(err);
}
/*
* Add listener.
*/
myEmitter.on('myevent', function(a, b, c) {
console.log(a, b, c);
});
event String
Name of event.
listener Function
Event handler function.
observer Object
Object reference for binding.
return: Object
This object.
Adds a 'listener' on 'event' to this EventEmitter instance which is removed after one 'event'.
Example:
/*
* Add one-time listener.
*/
myEmitter.once('myobjectevent', function(event) {
console.log(event);
});
String
Name of event.Function
Event handler function.Object
Object reference for binding.Object
This object.Removes a 'listener' on 'event', or all listeners on 'event', or all listeners from this EventEmitter instance.
Example:
/*
* Remove specific listener.
*/
function specific(event) {
console.log(event);
}
myEmitter.on('specific', specific);
myEmitter.off('specific', specific);
/*
* Remove all listeners on same event.
*/
myEmitter.off('same');
/*
* Remove All listeners.
*/
myEmitter.off();
String
Name of event.Arguments
All other arguments
to be emitted to listeners.Object
This object.Emits an 'event' with 'args' on this EventEmitter instance.
Example:
/*
* Emits 1, 2, 3 on 'myevent' listener(s).
*/
myEmitter.emit('myevent', 1, 2, 3);
String
Name of event.Object
An event object to be emitted to listeners.Object
This object.Emits an event object containing 'eventObject' on this EventEmitter instance.
Example:
/*
* Emits {eventData: 'data'} on 'myobjectevent' listener(s).
*/
myEmitter.emitEvent('myobjectevent', {eventData: 'data'});
FAQs
A generator for EventEmitter, lets you create an objects that can emit events.
The npm package generate-js-events receives a total of 4 weekly downloads. As such, generate-js-events popularity was classified as not popular.
We found that generate-js-events demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.